/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.isn.examenes.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author pool
 */
@Entity
@Table(name = "examen")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Examen.findAll", query = "SELECT e FROM Examen e"),
    @NamedQuery(name = "Examen.findByCodExa", query = "SELECT e FROM Examen e WHERE e.codExa = :codExa"),
    @NamedQuery(name = "Examen.findByDescExa", query = "SELECT e FROM Examen e WHERE e.descExa = :descExa")})
public class Examen implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "Cod_Exa", columnDefinition="CHAR(5) unsigned")
    private String codExa;
    @Column(name = "Desc_Exa")
    private String descExa;
    @JoinColumn(name = "Cod_Tipo_Exa", referencedColumnName = "Cod_Tipo_Exa")
    @ManyToOne(optional = false)
    private TipoDeExamen codTipoExa;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "examen")
    private Collection<DetalleOrdenexamen> detalleOrdenexamenCollection;

    public Examen() {
    }

    public Examen(String codExa) {
        this.codExa = codExa;
    }

    public String getCodExa() {
        return codExa;
    }

    public void setCodExa(String codExa) {
        this.codExa = codExa;
    }

    public String getDescExa() {
        return descExa;
    }

    public void setDescExa(String descExa) {
        this.descExa = descExa;
    }

    public TipoDeExamen getCodTipoExa() {
        return codTipoExa;
    }

    public void setCodTipoExa(TipoDeExamen codTipoExa) {
        this.codTipoExa = codTipoExa;
    }

    @XmlTransient
    public Collection<DetalleOrdenexamen> getDetalleOrdenexamenCollection() {
        return detalleOrdenexamenCollection;
    }

    public void setDetalleOrdenexamenCollection(Collection<DetalleOrdenexamen> detalleOrdenexamenCollection) {
        this.detalleOrdenexamenCollection = detalleOrdenexamenCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codExa != null ? codExa.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Examen)) {
            return false;
        }
        Examen other = (Examen) object;
        if ((this.codExa == null && other.codExa != null) || (this.codExa != null && !this.codExa.equals(other.codExa))) {
            return false;
        }
        return true;
    }
    
}
